package com.zjj.learn.designmodel.pattern.command;

import java.util.ArrayList;

/**
 * *** @author zjj_admin
 * *** 2022/4/17 22:17
 */
public class Waitor {

    private ArrayList<Command> commands ;

    public Waitor(){
        commands = new ArrayList<>();
    }

    public void setCommand(Command command) {
        this.commands.add(command);
    }

    public void orderUp(){
        System.out.println("美女服务员：叮咚，大厨，新订单来了.......");
        for (int i = 0; i < commands.size(); i++) {
            Command cmd = commands.get(i);
            if (cmd != null) {
                cmd.execute();
            }
        }
    }
}
